﻿@model  Model.PageRole
@{
    ViewBag.Title = "模型渐变维度列表";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <script type="text/javascript">
        var UrlArray = $.getUrlArray();
        var pageRole = '@Model.role';
        var retArr = new Array();
        var opts = {
            rows: 15,
            height: 450,
            url: "/ModelConfig/GetRecordList",
            para: { ModelID: UrlArray["modelID"], tableName: $("#txt_TableName").val(), dbName: encodeURI(UrlArray["dbName"]) },
            idField: "GUID",
            columns: [
                    { field: 'TableName', title: '名称', width: 30 },
                    { field: 'TableDescription', title: '描述', width: 30 },
                    { field: 'CreateTime', title: '创建时间', width: 8, align: 'center' },
                    { field: 'VersionTime', title: '版本时间', width: 16, align: 'center'  },
                    { field: 'Version', title: '模型版本', width: 8, align: 'center' },
                    { field: 'GUID', title: '操作', width: 8, align: 'center', formatter: function (value, rowData, rowIndex) {
                        var a = "<select onchange=\"DoAction(this.options.selectedIndex," + rowData.Version + ")\"><option value=''>-请选择-</option>";
                        if (pageRole == '2')
                            return a + "<option>查看</option><option>删除</option></select>";
                        else
                            return a + "<option>查看</option></select>";
                    }
                    }
                    ]
        };
        $(function () {
            InitList();
        });
        function DoAction(i, t) {
            var v = UrlArray["modelID"];
            switch (i) {
                case 1:
                    addData(v, t);
                    break;
                case 2:
                    DelData(v, t);
                    break;
            }
        }
        function InitList() {
            opts.para["tableName"] = $.trim($("#txt_TableName").val());
            opts.para["Version"] = $.trim($("#txt_Version").val());
            opts.para["dbName"] = encodeURI(UrlArray["dbName"]);
            $("#DataGrid2").dg(opts);
        }
        function ModelTableInfo(v,tn, t) {
            showModalMany('Info', '/ODSConfig/TableInfo?modelID=' + v + '&version=' + t + '&tbName=' + tn + '&dbName=' + encodeURI(UrlArray["dbName"]), '900', '480');
            InitList();
        }
        function addData(id, t) {
            window.location = "/ModelConfig/Edit?modelID=" + id + '&version=' + t + "&dbName=" + encodeURI(UrlArray["dbName"]);
        }
        function back() {
            window.location = "/ModelConfig/Index?dbName=" + encodeURI(UrlArray["dbName"]);
        }
        function DelData(v, t) {
            if (confirm("确定要删除吗？")) {
                $.post("/ModelConfig/DeleteRecord", { id: v, version: t, dbName: encodeURI(UrlArray["dbName"]) }, function (result) {
                    if (result == "1") {
                        alert("操作成功。");
                        InitList();
                    }
                    else
                        $("#msg").html(result);
                });
            }
            InitList();
        }
    </script>
}
<div id="div_main" class="modelType ov" style="margin: 5px;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                模型渐变维度搜索
            </td>
            <td align="right">
                <input type="button" value="返回" class="button" onclick="back()" />
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td>
                模型名称：
                <input type="text" id="txt_TableName" style="width: 300px;" />
                模型版本：
                <input type="text" id="txt_Version" style="width: 100px;" />
                <input type="button" value="搜索" class="button" onclick="InitList()" />
            </td>
        </tr>
    </table>
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                模型渐变维度列表
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table id="DataGrid2" class="pagTable" cellpadding="0" cellspacing="0">
    </table>
    <div>
        <div id="Pagination" class="pagination">
        </div>
        <div id="loading" class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="msg">
    </div>
</div>
